<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
  <style>
    #tree_main {
      padding: 20px;
    }

    .child {
      padding-left: 40px;
    }
  </style>
</head>

<body>
  <div id="tree_main"></div>
  <script>
    const treeMain = document.getElementById('tree_main')
    const depts = [
      {
        id: '604e115c7bfcfa45d019d3e9',
        pid: '-1',
        name: '传智教育',
        code: '1',
        introduce: '程序员的摇篮',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '604e21feb205b95968e13129',
        pid: '',
        name: '总裁办',
        code: '1001',
        manager: '管理员',
        introduce: '公司战略部',
        createTime: '2021-03-14 22:47:25',
      },
      {
        id: '604e222bb205b95968e1312a',
        pid: '',
        name: '行政部',
        code: 'XZB',
        manager: '管理员',
        introduce: '行政部',
        createTime: '2021-03-14 22:47:25',
      },
      {
        id: '604e223fb205b95968e1312b',
        pid: '',
        name: '人事部',
        code: 'RSB',
        manager: '管理员',
        introduce: '人事部',
        createTime: '2021-03-14 22:47:25',
      },
      {
        id: '604e2251b205b95968e1312c',
        pid: '',
        name: '财务部',
        code: 'CWB',
        manager: '管理员',
        introduce: '财务部',
        createTime: '2021-03-14 22:47:25',
      },
      {
        id: '604e2262b205b95968e1312d',
        pid: '604e2251b205b95968e1312c',
        name: '财务核算部',
        code: 'CWHSB',
        manager: '管理员',
        introduce: '财务核算部',
        createTime: '2021-03-14 22:47:25',
      },
      {
        id: '604e227db205b95968e1312e',
        pid: '604e2251b205b95968e1312c',
        name: '税务管理部',
        code: 'SWGLN',
        manager: '管理员',
        introduce: '税务管理部',
        createTime: '2021-03-14 22:47:25',
      },
      {
        id: '604e2297b205b95968e1312f',
        pid: '604e2251b205b95968e1312c',
        name: '薪资管理部',
        code: 'XZGLB',
        manager: '管理员',
        introduce: '薪资管理部',
        createTime: '2021-03-14 22:47:25',
      },
      {
        id: '6051ad90e93db6522c1d00d2',
        pid: '',
        name: '技术部',
        code: 'JSB',
        manager: '孙财',
        introduce: '技术部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6051adb6e93db6522c1d00d3',
        pid: '6051ad90e93db6522c1d00d2',
        name: 'Java研发部',
        code: 'JYFB',
        manager: '管理员',
        introduce: 'JAVA研发部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6051add6e93db6522c1d00d4',
        pid: '6051ad90e93db6522c1d00d2',
        name: 'Python研发部',
        code: 'PYFB',
        manager: '罗晓晓',
        introduce: 'Python研发部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6051adefe93db6522c1d00d5',
        pid: '6051ad90e93db6522c1d00d2',
        name: 'Php研发部',
        code: 'PhpYFB',
        manager: '孙财',
        introduce: 'Php研发部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6051ae03e93db6522c1d00d6',
        pid: '',
        name: '运营部',
        code: 'YYB',
        manager: '孙财',
        introduce: '运营部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6051ae15e93db6522c1d00d7',
        pid: '',
        name: '市场部',
        code: 'SCB',
        manager: '孙财',
        introduce: '市场部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6051ae28e93db6522c1d00d8',
        pid: '6051ae15e93db6522c1d00d7',
        name: '北京事业部',
        code: 'BJSYB',
        manager: '孙财',
        introduce: 'BJSYB',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6051ae3de93db6522c1d00d9',
        pid: '6051ae15e93db6522c1d00d7',
        name: '上海事业部',
        code: 'SHSYB',
        manager: '文吉星',
        introduce: '上海事业部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6409d488f034f87e1eafd8da',
        pid: '604e21feb205b95968e13129',
        name: '12',
        code: '341323',
        manager: '选项2',
        introduce: '3123123',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '6409d49ef034f87e1eafd8db',
        pid: '6051ae3de93db6522c1d00d9',
        name: '上海事业',
        code: 'SHSY',
        manager: '文吉星',
        introduce: '上海事业部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6409d56df034f87e1eafd90c',
        pid: '604e21feb205b95968e13129',
        name: '小黑子李成',
        code: 'h',
        manager: '孙财',
        introduce: 'h',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '6409d59cf034f87e1eafd90e',
        pid: '',
        name: '111',
        code: '11',
        manager: '厉不厉害你坤哥',
        introduce: '111111111111',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '6409d66bf034f87e1eafd91b',
        pid: '604e222bb205b95968e1312a',
        name: 'adas',
        code: 'asd',
        manager: '管理员',
        introduce: '行政部',
        createTime: '2021-03-14 22:47:25',
      },
      {
        id: '6409d67cf034f87e1eafd91c',
        pid: '6051adb6e93db6522c1d00d3',
        name: 'asd',
        code: 'asdasd',
        manager: '厉不厉害你坤哥',
        introduce: 'JAVA研发部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6409d6f6f034f87e1eafd92a',
        name: '1233333',
        code: '123',
        manager: '罗晓晓',
        introduce: '123',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '6409d71ff034f87e1eafd92d',
        pid: '6051ad90e93db6522c1d00d2',
        name: 'Php研发部1',
        code: 'PhpYFB1',
        manager: '乔海',
        introduce: 'Php研发部',
        createTime: '2021-03-17 15:18:23',
      },
      {
        id: '6409de32f034f87e1eafd99e',
        pid: '6051ae03e93db6522c1d00d6',
        name: '运营部一子部门',
        code: '运营部一子部门',
        manager: '罗晓晓',
        introduce: '运营部一子部门',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '6409de3df034f87e1eafd99f',
        pid: '6409de32f034f87e1eafd99e',
        name: '运营部二子部门',
        code: '运营部二子部门',
        manager: '罗晓晓',
        introduce: '运营部二子部门',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '6409de47f034f87e1eafd9a0',
        pid: '6409de3df034f87e1eafd99f',
        name: '运营部三子部门',
        code: '运营部三子部门',
        manager: '罗晓晓',
        introduce: '运营部三子部门',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '6409de52f034f87e1eafd9a1',
        pid: '6409de47f034f87e1eafd9a0',
        name: '运营部四子部门',
        code: '运营部四子部门',
        manager: '罗晓晓',
        introduce: '运营部四子部门',
        createTime: '2023-03-03 09:15:27',
      },
      {
        id: '6409de66f034f87e1eafd9a2',
        pid: '6409de52f034f87e1eafd9a1',
        name: '运营部五子部门',
        code: '运营部五子部门',
        manager: '罗晓晓',
        introduce: '运营部五子部门',
        createTime: '2023-03-03 09:15:27',
      },
    ]

    const op = document.querySelector('#tree_main')

    const obj = JSON.parse(JSON.stringify(depts))
    for (let k in obj) {
      const jias = {}

      if (obj[k].pid === '604e21feb205b95968e13129') {
        
        
      } else if (obj[k].id === '604e21feb205b95968e13129') {
        op.innerHTML = obj[k].name
      } 
    }


  </script>
</body>

</html>